package com.zrrd.straw1.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HelloController {
    //如果有控制器映射，先走控制器映射，没有再走 static
    @GetMapping("/test.html")
    public String method2(){
        return "test";
    }



    //步骤6：设置一个访问权限( 角色，访问地址 )
    //表示必须拥有”/zrrd/23-1“的用户才可以访问当前方法
    //@PreAuthorize("hasAuthority('/zrrd/23-1')")
    @GetMapping("/hello")
    @ResponseBody
    public String sayHello(){
        return "Hello";
    }
    @GetMapping("/welcome")
    @ResponseBody
    public String welcome(){ return "Welcome" ; }
}
